<template>
  <vxe-modal
    title="查看预算信息"
    v-model="dialogVisible"
    v-if="dialogVisible"
    :loading="loading"
    width="70%"  showFooter esc-closable show-zoom resize>

    <div style="height: 65vh; overflow-y: auto;">
      <el-card class="box-card" shadow="never" :body-style="{ padding: '10px',backgroundColor: '#bfcdda' }">
        <!-- 基本信息 -->
        <el-card class="box-card" shadow="hover">
          <div slot="header" class="clearfix">
            <span style="font-size: 16px; color: #1890ff;">基本信息</span>
          </div>
          <el-descriptions class="margin-top" :column="2" size="medium" border
                           :contentStyle="content_style" :labelStyle="label_style">
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  所属单位：
                </div>
              </template>
              {{ yssbData.ssDw }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  当年预算产值(万)：
                </div>
              </template>
              {{ yssbData.dnYsCz }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  科技投入(万)：
                </div>
              </template>
              {{ yssbData.kjTr }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  研发投入(万)：
                </div>
              </template>
              {{ yssbData.yfTr }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  填表人：
                </div>
              </template>
              {{ yssbData.tbr }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <div class="right-align-label">
                  <i class="el-icon-user"></i>
                  联系电话：
                </div>
              </template>
              {{ yssbData.lxPhone }}
            </el-descriptions-item>

          </el-descriptions>
        </el-card>
        <br>
        <!-- 相关附件 -->
        <el-card class="box-card" shadow="hover" style="min-height: 25vh">
          <div slot="header" class="clearfix">
            <span style="font-size: 16px; color: #1890ff;">相关附件</span>
          </div>
          <el-table height="30vh" :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                    :data="ysglYssbFjList">
            <el-table-column label="序号" align="center" type="index" width="50"/>
            <el-table-column label="文件名称" align="center" :formatter="getFileNames" prop="fileName"/>
            <el-table-column label="文件大小" align="center" prop="fileSize" width="150"/>
            <el-table-column label="操作" align="center" width="150">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="handleDownload(scope.row)"
                >下载
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <!--        <br>-->

      </el-card>
    </div>

    <div slot="footer" class="dialog-footer dialog-footer-center">
      <el-button @click="dialogVisible=false">关闭</el-button>
    </div>
  </vxe-modal>
</template>
<script>

import {getYssb} from "@/api/xmgl/ysgl/yssb";

export default {
  name: "YsSbXq", //预算申报详情组件
  dicts: ['sys_user_sex', 'rcpt_zc', 'rcpt_sxly', 'rcpt_ryfl', 'rcpt_sf'],
  data() {
    return {
      loading: false,
      yssbData: [], //合同基本信息与附件信息
      // 预算申报附件表格数据
      ysglYssbFjList: [],
      yssbId: null, //预算申报主键ID
      beforeData: [],
      beforeDataLoading: false,
      denyTo: null,
      dialogVisible: false,
      rowData: null,
      submitType: "1",//默认同意
      comment: null,//审批意见
      businessData: null,//业务数据
      historyList: [],//历史信息
      content_style: {
        // 解决不对齐的问题
        'width': "400px",
        // 排列第二行
        'word-break': 'break-all',
        // 'background-color': '#f3f7ff'
      },
      label_style: {
        // 解决不对齐的问题
        'width': "250px",
        // 排列第二行
        'word-break': 'break-all',
      },
    };
  },
  created() {
  },
  methods: {
    // 文件下载处理
    handleDownload(row) {
      const resource = row.fileName;
      // 默认方法
      this.$download.resource(resource);
    },
    getFileNames(row) {
      // 从路径中提取文件名
      return row.fileName.split('/').pop(); // 返回文件名部分
    },
    handleOpen(row) {
      this.rowData = row
      this.loading = true;
      this.yssbId = row.yssbId
      this.dialogVisible = true
      this.getYsSbData()
      setTimeout(() => {
        this.loading = false
      }, 1000)
    },
    //获取详情数据
    getYsSbData() {
      const yssbId = this.yssbId
      getYssb(yssbId).then(res => {
        this.yssbData = res.data
        this.ysglYssbFjList = res.data.ysglYssbFjList;
      })
    },


  }
};
</script>

